package com.neusoft.neu24g3.myhis2.demos.web;

import lombok.Data;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * GetRestController asdf
 *
 * @author Administrator
 * @version 2024/05/27 15:32
 **/
@RestController
@RequestMapping("get")
@CrossOrigin("*")
public class GetRestController {
//    采用Form表单的get方式提交数据
    @GetMapping("f1")
//    获得Form表单的get风格是数据 ---  》   转化为简单的数据类型
//    http://localhost:8030/get/f1?wd=dog&price=5678&pass=23456
//     , @RequestParam Date  birthday
    public String f1(int price, String wd  , boolean pass, @RequestParam Date  birthday){
        System.out.println(wd );
        System.out.println("price = " + price);
        System.out.println("pass = " + pass);
        System.out.println("birthday = " + birthday);
        return "get f1";
    }
    //    获得Form表单的get风格是数据 ---  》   转化为Porject
//    form的key必须于类的属性名一致，与类名无关
//    http://localhost:8030/get/f1?wd=dog&price=5678&pass=23456

    @GetMapping("f2")
    public String f2(  Dog  dog ){
        System.out.println("GetRestController.f2");
        System.out.println(dog);
        return "get f1";
    }
//    RESTful
//    所有的参数都根据位置写在url路径中，PathVariable 可以获得任意请求（get，post等）路径中的数据
//      name =  dog, age =18, price = 5678
// http://localhost:8030/get/f3/dog/18/5678
    @GetMapping("f3/{name}/{age}/{price}")
    public String f3(@PathVariable( "name" ) String  name   , @PathVariable( "age" ) Integer  age  , @PathVariable( "price" ) Integer  price  ){
        System.out.println("GetRestController.f3");
        System.out.println("xyz = " + name);
        System.out.println("age = " + age);
        System.out.println("price = " + price);

        return "get f3";
    }

}

